hysop.topology.topology module

Definitions for hysop topologies * TopologyState * TopologyView * Topology

class hysop.topology.topology.Topology(domain, mpi_params=None, backend=HOST(1), cl_env=None, allocator=None, queue=None, **kwds)[source]

Bases: RegisteredObject

Abstract base class for hysop Topologies.

In hysop, a topology is defined as the association of a mpi process distribution (mpi topology) and of a set of local meshes (one per process).

At the time, only CartesianTopology topologies with cartesian meshes are available.

For details about topologies see HySoP User Manual. You can also find examples of topologies instanciation in test_topology.py.

Initialize this object. If self._initialized was already set to True, raise a RuntimeError. Else, set self._initialized to True.

static __new__(cls, domain, mpi_params=None, backend=HOST(1), cl_env=None, allocator=None, queue=None, **kwds)[source]

Creates or get an existing topology.

Parameters:
  • domain (Domain) – the geometry on which the topology is defined.

  • mpi_params (MPIParams, optional) – MPI parameters (comm, task …). If not specified, comm = domain.task_comm, task = domain.curent_task()

  • backend (Backend or ~hysop.core.arrays.ArrayBackend, optional) – Backend or backend kind for this topology. By default a topology will use Backend.HOST.

  • allocator (Allocator, optional) – Allocated used on HOST backends instead of the default host memory pool allocator. Only used if the backend is Backend.HOST.

  • cl_env (OpenClEnvironment, optional) – Topology will use this specified OpenClEnvironment when backend is Backend.OPENCL. By default a new environment is created with get_or_create_opencl_env(mpi_params.comm)

  • queue (pyopencl.Queue, optional) – Default queue used for OpenCL Arrays. By default this queue will be cl_env.default_queue. Only used if the backend is Backend.OPENCL.

  • kwds (dict) – Base class keyword arguments.

  • Notes

  • ------

  • RegisteredObjects. (Topologies can be uniquely identified by their id as they are hysop)

:param See RegisteredObject for more information.:

abstract discretize(field)[source]

Discretize a continous field on this topology and return a DiscreteField.

abstract view(topology_state)[source]

Return a TopologyView of this topology with a specific state.

class hysop.topology.topology.TopologyState(is_read_only, **kwds)[source]

Bases: TaggedObject

Abstract base to define TopologyStates.

A TopologyState is a topology dependent state, and acts as a virtual state that determines how we should perceive raw mesh data.

A TopologyState may for example include a transposition state like for CartesianTopology topologies.

Initialize a topology state.

__str__()[source]

Same as self.long_description()

abstract copy(is_read_only=None, **kwds)[source]

Return a copy of self, some properties may be alterted in kwds.

property is_read_only

Return true if this topology is read only.

abstract long_description()[source]

Long description of this topology state.

abstract match(other, invert=False)[source]

Check if this topology state does match the other one.

abstract short_description()[source]

Short description of this topology state.

class hysop.topology.topology.TopologyView(topology_state, topology=None, **kwds)[source]

Bases: TaggedObjectView

Abstract base to define views on a Topology dependening on a TopologyState.

A TopologyView is a view on a Topology altered by a TopologyState. It is a lightweight object that keeps a reference on a Topology and a TopologyState.

A CartesianTopologyState may for example include a transposition state for CartesianTopology topologies, resulting in the automatic permutation of attributes when fetching the view attributes (global_resolution and ghosts will be transposed).

Create and initialize a TopologyView on given topology.

Parameters:
  • topology_state (TopologyState) – State that charaterizes the given view.

  • topology (Topology) – Original topology on which the view is.

  • kwds (dict) – Base class keyword arguments.

topology

Original topology on which the view is.

Type:

Topology

topology_state

State that charaterizes the given view.

Type:

TopologyState

domain

The geometry on which the topology is defined.

Type:

Domain

backend

ArrayBackend of this topology.

Type:

ArrayBackend

mpi_params

The parent MPI parameters of this topology. /!Topologies may define a sub communicator (CartesianTopology topologies will define a MPI.Cartcomm for example).

Type:

MPIParams

parent

Return the parent communicator used to build this topology.

Type:

IntraComm

task_id

Returns id of the task that owns this topology.

Type:

int

Notes

All attributes are read-only properties.

static __new__(cls, topology_state, topology=None, **kwds)[source]

Create and initialize a TopologyView on given topology.

Parameters:
  • topology_state (TopologyState) – State that charaterizes the given view.

  • topology (Topology) – Original topology on which the view is.

  • kwds (dict) – Base class keyword arguments.

topology

Original topology on which the view is.

Type:

Topology

topology_state

State that charaterizes the given view.

Type:

TopologyState

domain

The geometry on which the topology is defined.

Type:

Domain

backend

ArrayBackend of this topology.

Type:

ArrayBackend

mpi_params

The parent MPI parameters of this topology. /!Topologies may define a sub communicator (CartesianTopology topologies will define a MPI.Cartcomm for example).

Type:

MPIParams

parent

Return the parent communicator used to build this topology.

Type:

IntraComm

task_id

Returns id of the task that owns this topology.

Type:

int

Notes

All attributes are read-only properties.

__str__()[source]

Same as self.long_description().

property backend

ArrayBackend of this topology.

abstract default_state()[source]

Return the default topology state of this topology.

property domain

The geometry on which the topology is defined.

property domain_dim

The geometry dimension on which the topology is defined.

abstract long_description(topo)[source]

Long description of this topology.

match(other, invert=False)[source]

Check if two TopologyViews are equivalent.

property mesh

Return a mesh view on local mesh.

property mpi_params

The parent MPI parameters of this topology. /!Topologies may define a sub communicator

CartesianTopology topologies will define a MPI.Cartcomm for example.

property parent

Return the communicator used to build this topology.

abstract short_description(topo)[source]

Short description of this topology.

property task_id

Returns id of the task that owns this topology.

property topology

Original topology on which the view is.

property topology_state

Original topology on which the view is.

exception hysop.topology.topology.TopologyWarning[source]

Bases: HysopWarning

Custom warning class for topology objects.